const { defineConfig } = require('@vue/cli-service')
const webpack = require('webpack')
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin')
const { ModuleFederationPlugin } = require("webpack").container;
const isProd=process.env.NODE_ENV === 'production'
const prodExternals = {
  // key表示包名(import foo from 'xx' 里的xx)
  // value表示window下的全局变量名(库暴露出来的namespace,可查lib对应的webpack配置里的library字段)
  'vue': 'Vue',
  'axios': 'axios',
  'vue-router': 'VueRouter',
  'ant-design-vue': 'antd',
};

module.exports = defineConfig({
  publicPath:'./',
  productionSourceMap:false,
  configureWebpack: {
   // externals: isProd?prodExternals:[],
    //devtool: 'source-map',
    plugins: [new NodePolyfillPlugin(),
      new webpack.IgnorePlugin({
        resourceRegExp: /^\.\/locale$/,
        contextRegExp: /moment$/,
      }),
      new ModuleFederationPlugin({
        // 唯一ID，用于标记当前服务
        name: "lanjian_pdfano",
        // 提供给其他服务加载的文件
        filename: "remoteEntry.js",
        // 需要暴露的模块，使用时通过 `${name}/${expose}` 引入
        exposes: {
          './PdfAno': "./src/packages/pdf-ano/src/index.vue"
        }
      }),
      new webpack.IgnorePlugin({
        resourceRegExp: /^\.\/locale$/,
        contextRegExp: /moment\//,
      })],
    output: {
      libraryExport: 'default'
    }
  },
  css: {
    loaderOptions: {
      less: {
        modifyVars: {
          'font-size-base': '18px',
        },
        javascriptEnabled: true,
        math: 'always',
      },

    },
  },
 // transpileDependencies: ['ant-design-vue'],
  lintOnSave:false //关闭eslint检查
})
